<template>
  <van-popup v-model:show="show" :position="position" round>
    <div class="container">
      <div class="title" v-if="title">{{ title }}</div>
      <div class="message">{{ message }}</div>
      <div class="footer">
        <div class="cancel-btn" @click="onCancel">取消</div>
        <div class="confirm-btn" @click="onConfirm">确定</div>
      </div>
    </div>
  </van-popup>
</template>

<script setup>
import { ref, reactive, onMounted } from 'vue';

const props = defineProps({
  show: {
    type: Boolean,
    default: false
  },
  position: {
    type: String,
    default: 'center'
  },
  title: {
    type: String,
    default: ''
  },
  message: {
    type: String,
    default: ''
  }
});

const show = defineModel('show');

const emit = defineEmits(['confirm', 'cancel']);

const onConfirm = () => {
  emit('confirm');
  show.value = false;
};

const onCancel = () => {
  show.value = false;
  emit('cancel');
};

onMounted(() => {});
</script>

<style scoped lang="scss">
.container {
  width: 380px;
  background-color: #fff;
  border-radius: 10px;
  padding: 20px;
  .title {
    text-align: center;
    font-size: 24px;
  }
  .message {
    text-align: center;
    font-size: 20px;
    color: #333;
    margin-top: 23px;
    padding: 20px 0;
  }
  .footer {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    .cancel-btn {
      width: 48%;
      text-align: center;
      font-size: 20px;
      padding: 8px 0;
      background-color: #fff;
      border: 1px solid $primary-color;
      border-radius: 6px;
      color: $primary-color;
    }
    .confirm-btn {
      width: 48%;
      font-size: 20px;
      padding: 8px 0;
      text-align: center;
      background-color: $primary-color;
      border-radius: 6px;
      color: #fff;
    }
  }
}
</style>
